-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add function to return a Certificate
from DER format
#293
Conversation
if worked, can add load_cert function
Hi @jiangshaoqi, thanks for the contribution. Can you speak more to your motivation for wanting this? You can already construct |
Hello @cpu , thank you for the reply. In Also, In my case, if i sign it again to get the Certificate, there will be some difference between my original certificate, because of x509 parser. for example, in my certificate: I also see people asking for: [https://github.com//issues/274] What i did work for me, and i think it might be good for others. From your reply, i think i should also try use rcgen generate a CA certificate DER, get its If it is same, please ignore my request |
I just checked: use rcgen generate a CA certificate DER, get its It also works in my scenario, please ignore my request and have a good day! |
@jiangshaoqi I would be curious how you achieved the same certificate because I can't seem to reproduce it myself. When I run the following code and the assertion fails: let CertifiedKey { cert, key_pair } = generate_simple_self_signed(vec!["abc".into()]).unwrap();
let before = cert.pem();
println!("{:?}", cert.pem());
println!("{:?}\n\n\n", key_pair.serialize_pem());
let key_pair = rcgen::KeyPair::from_pem(&key_pair.serialize_pem()).unwrap();
let cert = CertificateParams::from_ca_cert_der(&cert.try_into().unwrap())
.unwrap()
.self_signed(&key_pair)
.unwrap();
println!("{:?}", cert.pem());
println!("{:?}\n\n\n", key_pair.serialize_pem());
assert_eq!(before, cert.pem()); I kinda feel like this PR should be reopened and merged as a stop gap solution. |
add "from_der" function in the Certificate implementation. This function can create a Certificate struct from DER encoded certificate.
Make sure the certificate match the format of x509-parser in rcgen, or the generated
Certificate
will be different.A safe way of this usage is to load the DER certificate generated by rcgen itself.